package edu.webtek.cloudresp;

import java.util.ArrayList;
import java.util.Iterator;

import org.jdom2.Element;
import org.jdom2.Document;

import edu.webtek.clouddata.Item;

public class RespItems extends RespBase implements Iterable<Item>{
	final private ArrayList<Item> items = new ArrayList<Item>();
	
	public RespItems(Document resp) {
		if(resp == null){
			flagResponseError();
			return;
		}
		
		Element items = resp.getRootElement();
		for(Element item : items.getChildren()){
			this.items.add(new Item(item));
		}
	}
	
	@Override
	public Iterator<Item> iterator() {
		return items.iterator();
	}

}
